<?php
/**
 * Created by PhpStorm.
 * User: yanghe
 * Date: 2016/4/26
 * Time: 14:22
 */
namespace MyClass\Image;
use Illuminate\Support\Facades\DB;

class ImageBase
{
    public static function addImage()
    {
        if (request::hasFile('image_file')) {
            $file = Request::file('image_file');
            $fileName = $file->getClientOriginalName();
            $storage_path ="/../storage/photo/";
            $path=$_SERVER['DOCUMENT_ROOT'].$storage_path;//$_SERVER['DOCUMENT_ROOT']获取当前文件的根目录
            Request::file('image_file')->move($path, $fileName);
            $data["image_path"]=$path;
            $data["image_name"]=$fileName;
            $res=DB::table("image")->insert($data);
            if($res)
            {
                return "成功";
            }
            else
            {
                return "失败";
            }

        }
        else
        {
            return "上传失败";
        }
    }
}